import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


// // 获取原型对象上的push函数
// const originalPush = VueRouter.prototype.push
// // 修改原型对象中的push方法
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }

//引入路由组件(懒加载)
const Home = () => import('@pages/Home/Home.vue')
const Login = () => import('@pages/Login/Login.vue')
const Search = () => import('@pages/Search/Search.vue')
const Register = () => import('@pages/Register/Register.vue')


export default new VueRouter({
  mode: 'history',
  routes: [
    // 默认路由
    {
      path: '/',
      redirect: '/home'
    }, {
      path: "/home",
      component: Home,
      name: 'home'
    },
    {
      path: "/login",
      component: Login,
      name: 'login'
    },
    {
      path: "/register",
      component: Register,
      name: 'register'
    },
    {
      path: "/search",
      component: Search,
      name: 'Search'
    },
  ]
})